package com.example.sellqq.controller;

import com.example.sellqq.domain.AddressBook;
import com.example.sellqq.service.AddressBookService;
import com.example.sellqq.vo.ResponseVO;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;

/**
 * @Author: thekernel
 * @Date: 2020/4/24 22:47
 * @Version: 1.0
 * @Description:
 */
@Api(value = "通讯录Controller")
@RestController
@RequestMapping("address_book")
public class AddressBookController {

    @Autowired
    private AddressBookService addressBookService;

    @ApiIgnore
    @GetMapping("hello")
    public @ResponseBody
    String index() {
        return "Hello AddressBook !!!";
    }


    @GetMapping("all")
    public @ResponseBody
    ResponseVO getAll() {
        return this.addressBookService.getAllAddressBook();
    }

    @PostMapping("many")
    public @ResponseBody
    ResponseVO addMany(@RequestBody List<AddressBook> addressBooks) {
        return this.addressBookService.saveAddressBook(addressBooks);
    }

}
